package com.appwoo.txtws.activity;

import android.app.ProgressDialog;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import com.appwoo.android.exception.NotFoundNetWorkException;
import com.appwoo.android.exception.TimeOutException;
import com.appwoo.txtws.app.AppActivity;
import com.appwoo.txtws.bean.HomeBean;
import com.appwoo.txtws.component.DBHelper;
import com.appwoo.txtws.component.Global;
import com.appwoo.txtws.component.RqSP;
import com.appwoo.txtws.scroll.HomePageService;
import com.appwoo.txtws.service.TimerService;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParserException;

public class PCOneKeyActivity extends AppActivity
{
  private String alertString;
  private Button btnCut;
  private Button btnLock;
  private SharedPreferences.Editor editor;
  private String equipName;
  private HomeBean f_HomeBean;
  private HomePageService f_HomePageService;
  private int isOnline = 0;
  private LinearLayout pconekey;
  private SharedPreferences preferences;
  private RqSP rqsp;
  private TimerService timerService;
  private String userId;
  private ProgressDialog v_progressDialog = null;

  private void addListener()
  {
    quickCutListener();
    quickLockListener();
  }

  private String bgInitHomeBean()
  {
    try
    {
      this.f_HomeBean = this.f_HomePageService.getHomeBeanInfo(this.userId, this.equipName, this);
      return "";
    }
    catch (IOException localIOException)
    {
      this.alertString = getString(2131427525);
      return "";
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      this.alertString = getString(2131427525);
      return "";
    }
    catch (TimeOutException localTimeOutException)
    {
      this.alertString = getString(2131427526);
      return "";
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.getClass();
      this.alertString = "没有连接到网络";
      return "";
    }
    catch (Exception localException)
    {
      this.alertString = getString(2131427525);
    }
    return "";
  }

  private void bgShowHomeBean(String paramString)
  {
    if (this.f_HomeBean != null)
    {
      if ((this.f_HomeBean.getIsOnline() != null) && (!this.f_HomeBean.getIsOnline().equals("")))
      {
        if (Integer.parseInt(this.f_HomeBean.getIsOnline()) != 0)
          break label178;
        setBarTitle(getResources().getString(2131427345) + getResources().getString(2131428015));
        if ((this.f_HomeBean.getNetworkStatus() != null) && (!this.f_HomeBean.getNetworkStatus().equals("")))
        {
          if (Integer.parseInt(this.f_HomeBean.getNetworkStatus()) != 3)
            break label224;
          setNetButton(Boolean.valueOf(true));
        }
      }
      while (true)
      {
        if ((this.f_HomeBean.getScreenStatus() != null) && (!this.f_HomeBean.getScreenStatus().equals("")))
        {
          if (Integer.parseInt(this.f_HomeBean.getScreenStatus()) != 2)
            break label235;
          setLockButton(Boolean.valueOf(true));
        }
        return;
        label178: setBarTitle(getResources().getString(2131427345) + getResources().getString(2131428014));
        this.isOnline = 1;
        break;
        label224: setNetButton(Boolean.valueOf(false));
      }
      label235: setLockButton(Boolean.valueOf(false));
      return;
    }
    alertMessage(this.alertString);
  }

  private void createOrShowDialog()
  {
    if ((this.v_progressDialog == null) || (!this.v_progressDialog.isShowing()))
    {
      this.v_progressDialog = new ProgressDialog(this);
      this.v_progressDialog.setMessage(getString(2131427516));
      this.v_progressDialog.setCancelable(true);
      this.v_progressDialog.show();
    }
  }

  private void initActionBar()
  {
    hideBarHome();
    setBarTitle(getResources().getString(2131427345));
    setBarBackOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        PCOneKeyActivity.this.finish();
      }
    });
  }

  private void initView()
  {
    this.btnCut = ((Button)findViewById(2131493304));
    this.btnLock = ((Button)findViewById(2131493305));
    this.f_HomePageService = new HomePageService();
    this.rqsp = new RqSP();
    this.equipName = this.rqsp.getLgDevId(this);
    this.userId = this.rqsp.getLgDevAccount(this);
    this.timerService = new TimerService();
    getSharedPreferences("equipname", 0);
    this.preferences = getSharedPreferences("cutnet", 0);
    this.editor = this.preferences.edit();
  }

  private void quickCutListener()
  {
    this.btnCut.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        new DBHelper(PCOneKeyActivity.this).insertModuleAccess(Global.ManageUserName, Global.getIMEI(PCOneKeyActivity.this), PCOneKeyActivity.this.getResources().getStringArray(2131165189)[0], PCOneKeyActivity.this.getResources().getStringArray(2131165189)[1]);
        PCOneKeyActivity.HomeAsyncTask localHomeAsyncTask = new PCOneKeyActivity.HomeAsyncTask(PCOneKeyActivity.this);
        if ((PCOneKeyActivity.this.f_HomeBean != null) && (PCOneKeyActivity.this.f_HomeBean.getNetworkStatus() != null))
        {
          if (!PCOneKeyActivity.this.f_HomeBean.getNetworkStatus().equals("1"))
            break label123;
          localHomeAsyncTask.execute(new String[] { "connect" });
        }
        label123: 
        while (((!PCOneKeyActivity.this.f_HomeBean.getNetworkStatus().equals("3")) && (!PCOneKeyActivity.this.f_HomeBean.getNetworkStatus().trim().equals(""))) || (PCOneKeyActivity.this.f_HomeBean.getIsOnline() == null) || (PCOneKeyActivity.this.f_HomeBean.getIsOnline().equals("")))
          return;
        if (Integer.parseInt(PCOneKeyActivity.this.f_HomeBean.getIsOnline()) == 0)
        {
          PCOneKeyActivity.this.alertMessage(PCOneKeyActivity.this.getResources().getString(2131427488));
          return;
        }
        localHomeAsyncTask.execute(new String[] { "cut" });
      }
    });
  }

  private void quickLockListener()
  {
    this.btnLock.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        new DBHelper(PCOneKeyActivity.this).insertModuleAccess(Global.ManageUserName, Global.getIMEI(PCOneKeyActivity.this), PCOneKeyActivity.this.getResources().getStringArray(2131165190)[0], PCOneKeyActivity.this.getResources().getStringArray(2131165190)[1]);
        PCOneKeyActivity.HomeAsyncTask localHomeAsyncTask = new PCOneKeyActivity.HomeAsyncTask(PCOneKeyActivity.this);
        if ((PCOneKeyActivity.this.f_HomeBean != null) && (PCOneKeyActivity.this.f_HomeBean.getScreenStatus() != null))
        {
          if (!PCOneKeyActivity.this.f_HomeBean.getScreenStatus().equals("0"))
            break label123;
          localHomeAsyncTask.execute(new String[] { "open" });
        }
        label123: 
        while (((!PCOneKeyActivity.this.f_HomeBean.getScreenStatus().equals("2")) && (!PCOneKeyActivity.this.f_HomeBean.getScreenStatus().trim().equals(""))) || (PCOneKeyActivity.this.f_HomeBean.getIsOnline() == null) || (PCOneKeyActivity.this.f_HomeBean.getIsOnline().equals("")))
          return;
        if (Integer.parseInt(PCOneKeyActivity.this.f_HomeBean.getIsOnline()) == 0)
        {
          PCOneKeyActivity.this.alertMessage(PCOneKeyActivity.this.getResources().getString(2131427488));
          return;
        }
        localHomeAsyncTask.execute(new String[] { "lock" });
      }
    });
  }

  private String quickSubmit(String paramString)
  {
    this.alertString = "";
    try
    {
      this.alertString = this.f_HomePageService.quickSubmitFromP(this.userId, this.equipName, paramString, this);
      return this.alertString;
    }
    catch (IOException localIOException)
    {
      while (true)
        this.alertString = getString(2131427525);
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      while (true)
        this.alertString = getString(2131427525);
    }
    catch (TimeOutException localTimeOutException)
    {
      while (true)
        this.alertString = getString(2131427526);
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      while (true)
      {
        localNotFoundNetWorkException.getClass();
        this.alertString = "没有连接到网络";
      }
    }
  }

  private void setLockButton(Boolean paramBoolean)
  {
    int i = this.btnLock.getPaddingLeft();
    int j = this.btnLock.getPaddingTop();
    int k = this.btnLock.getPaddingRight();
    int m = this.btnLock.getPaddingBottom();
    if (paramBoolean.booleanValue())
    {
      this.btnLock.setTextColor(getResources().getColor(2131230728));
      this.btnLock.setText(getString(2131427681));
      this.btnLock.setBackgroundDrawable(getResources().getDrawable(2130837632));
      this.btnLock.setPadding(i, j, k, m);
      this.f_HomeBean.setScreenStatus("2");
      return;
    }
    this.btnLock.setTextColor(getResources().getColor(2131230724));
    this.btnLock.setText(getString(2131427680));
    this.btnLock.setBackgroundDrawable(getResources().getDrawable(2130837636));
    this.btnLock.setPadding(i, j, k, m);
    this.f_HomeBean.setScreenStatus("0");
  }

  private void setNetButton(Boolean paramBoolean)
  {
    int i = this.btnCut.getPaddingLeft();
    int j = this.btnCut.getPaddingTop();
    int k = this.btnCut.getPaddingRight();
    int m = this.btnCut.getPaddingBottom();
    if (paramBoolean.booleanValue())
    {
      this.btnCut.setTextColor(getResources().getColor(2131230728));
      this.btnCut.setText(getString(2131427677));
      this.btnCut.setBackgroundDrawable(getResources().getDrawable(2130837632));
      this.btnCut.setPadding(i, j, k, m);
      this.f_HomeBean.setNetworkStatus("3");
      return;
    }
    this.btnCut.setTextColor(getResources().getColor(2131230724));
    this.btnCut.setText(getString(2131427673));
    this.btnCut.setBackgroundDrawable(getResources().getDrawable(2130837636));
    this.btnCut.setPadding(i, j, k, m);
    this.f_HomeBean.setNetworkStatus("1");
  }

  private void showView()
  {
    new HomeAsyncTask().execute(new String[] { "init" });
  }

  protected void backKeyCallBack()
  {
    finish();
  }

  public void onBackPressed()
  {
    finish();
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903165);
    initActionBar();
    initView();
    addListener();
  }

  protected void onResume()
  {
    super.onResume();
    showView();
  }

  public class HomeAsyncTask extends AsyncTask<String, Integer, String>
  {
    private String method = "";

    public HomeAsyncTask()
    {
    }

    protected String doInBackground(String[] paramArrayOfString)
    {
      this.method = paramArrayOfString[0];
      if (this.method.equals("init"))
        return PCOneKeyActivity.this.bgInitHomeBean();
      if (this.method.equals("refash"))
        return PCOneKeyActivity.this.bgInitHomeBean();
      if (this.method.equals("cut"))
        return PCOneKeyActivity.this.quickSubmit("1");
      if (this.method.equals("connect"))
        return PCOneKeyActivity.this.quickSubmit("3");
      if (this.method.equals("open"))
        return PCOneKeyActivity.this.quickSubmit("2");
      if (this.method.equals("lock"))
        return PCOneKeyActivity.this.quickSubmit("0");
      return "";
    }

    protected void onPostExecute(String paramString)
    {
      if ((this.method.equals("init")) || (this.method.equals("refash")))
        PCOneKeyActivity.this.bgShowHomeBean(paramString);
      try
      {
        while (true)
        {
          PCOneKeyActivity.this.v_progressDialog.dismiss();
          return;
          if (this.method.equals("cut"))
          {
            if (paramString.equals("0"))
            {
              PCOneKeyActivity.this.alertMessage(PCOneKeyActivity.this.getString(2131427671));
              PCOneKeyActivity.this.setNetButton(Boolean.valueOf(false));
            }
            else
            {
              PCOneKeyActivity.this.alertMessage(PCOneKeyActivity.this.getString(2131427674));
            }
          }
          else if (this.method.equals("connect"))
          {
            if (paramString.equals("0"))
            {
              PCOneKeyActivity.this.alertMessage(PCOneKeyActivity.this.getString(2131427675));
              PCOneKeyActivity.this.setNetButton(Boolean.valueOf(true));
            }
            else
            {
              PCOneKeyActivity.this.alertMessage(PCOneKeyActivity.this.getString(2131427674));
            }
          }
          else if (this.method.equals("lock"))
          {
            if (paramString.equals("0"))
            {
              PCOneKeyActivity.this.alertMessage(PCOneKeyActivity.this.getString(2131427678));
              PCOneKeyActivity.this.setLockButton(Boolean.valueOf(false));
            }
            else
            {
              PCOneKeyActivity.this.alertMessage(PCOneKeyActivity.this.getString(2131427674));
            }
          }
          else if (this.method.equals("open"))
            if (paramString.equals("0"))
            {
              PCOneKeyActivity.this.alertMessage(PCOneKeyActivity.this.getString(2131427682));
              PCOneKeyActivity.this.setLockButton(Boolean.valueOf(true));
            }
            else
            {
              PCOneKeyActivity.this.alertMessage(PCOneKeyActivity.this.getString(2131427674));
            }
        }
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
      }
    }

    protected void onPreExecute()
    {
      PCOneKeyActivity.this.createOrShowDialog();
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.PCOneKeyActivity
 * JD-Core Version:    0.6.2
 */